import 'package:dio/dio.dart';
import 'package:flutter_wan_android/data/banner/banner_entity.dart';
import 'package:flutter_wan_android/data/base_data_layer_api.dart';
import 'package:flutter_wan_android/data/wan_android_resp.dart';

import '../../core/http/network_module.dart';

class BannerNetworkApi {
  late final Dio _dio;

  BannerNetworkApi(NetworkModule module) {
    _dio = module.dio;
  }

  Future<List<BannerEntity>> requestList() {
    return performNetworkRequest(
      () => _dio.get("banner/json"),
      (body) => WanAndroidResp<List<BannerEntity>>.fromJson(
        body,(data) =>
            (data as List)
                .map(
                  (item) => BannerEntity.fromJson(item as Map<String, dynamic>),
                )
                .toList(),
      ),
    );
  }
}
